|
1
|
|
|
/* global describe, it */ |
|
2
|
|
|
const chai = require('chai') |
|
3
|
|
|
const dirtyChai = require('dirty-chai') |
|
4
|
|
|
chai.use(dirtyChai) |
|
5
|
|
|
chai.should() |
|
6
|
|
|
const expect = chai.expect |
|
7
|
|
|
const signalkSchema = require('../dist/') |
|
8
|
|
|
|
|
9
|
|
|
describe('metadata:getUnits', function () { |
|
10
|
|
|
it('Valid simple getUnits works', function () { |
|
11
|
|
|
signalkSchema.getUnits('vessels.foo.navigation.speedOverGround').should.equal('m/s') |
|
12
|
|
|
}) |
|
13
|
|
|
|
|
14
|
|
|
it('Valid complex path getUnits works', function () { |
|
15
|
|
|
signalkSchema.getUnits('vessels.foo.propulsion.0.oilTemperature').should.equal('K') |
|
16
|
|
|
}) |
|
17
|
|
|
|
|
18
|
|
|
it('Invalid getUnits returns undefined', function () { |
|
19
|
|
|
expect(signalkSchema.getUnits('vessels.foo.bar.0.oilTemperature')).to.be.undefined() |
|
20
|
|
|
}) |
|
21
|
|
|
}) |
|
22
|
|
|
|
|
23
|
|
|
describe('metadata:getMetadata', function () { |
|
24
|
|
|
it('Valid simple getMetadata works', function () { |
|
25
|
|
|
signalkSchema.getMetadata('vessels.foo.navigation.speedOverGround').should.deep.equal({ |
|
26
|
|
|
units: 'm/s', |
|
27
|
|
|
description: "Vessel speed over ground. If converting from AIS 'HIGH' value, set to 102.2 (Ais max value) and add warning in notifications" |
|
28
|
|
|
}) |
|
29
|
|
|
}) |
|
30
|
|
|
|
|
31
|
|
|
it('Valid complex path getMetadata works', function () { |
|
32
|
|
|
signalkSchema.getMetadata('vessels.foo.propulsion.0.oilTemperature').should.deep.equal({ |
|
33
|
|
|
units: 'K', |
|
34
|
|
|
description: 'Oil temperature' |
|
35
|
|
|
}) |
|
36
|
|
|
}) |
|
37
|
|
|
|
|
38
|
|
|
it('Invalid getMetadata returns undefined', function () { |
|
39
|
|
|
expect(signalkSchema.getMetadata('vessels.foo.0.oilTemperature')).to.be.undefined() |
|
40
|
|
|
}) |
|
41
|
|
|
|
|
42
|
|
|
it('getMetadata for path with enum works', function () { |
|
43
|
|
|
expect( |
|
44
|
|
|
signalkSchema.getMetadata('vessels.foo.navigation.datetime.gnssTimeSource') |
|
45
|
|
|
).to.deep.equal({ |
|
46
|
|
|
description: 'Source of GNSS Date and Time', |
|
47
|
|
|
enum: [ |
|
48
|
|
|
'GPS', |
|
49
|
|
|
'GLONASS', |
|
50
|
|
|
'Galileo', |
|
51
|
|
|
'Beidou', |
|
52
|
|
|
'IRNSS', |
|
53
|
|
|
'Radio Signal', |
|
54
|
|
|
'Internet', |
|
55
|
|
|
'Local clock' |
|
56
|
|
|
] |
|
57
|
|
|
}) |
|
58
|
|
|
}) |
|
59
|
|
|
}) |
|
60
|
|
|
|
|
61
|
|
|
describe('getAISShipTypeName works', function () { |
|
62
|
|
|
it("ship type 20 is 'Wing In Ground'", function () { |
|
63
|
|
|
expect( |
|
64
|
|
|
signalkSchema.getAISShipTypeName(20) |
|
65
|
|
|
).to.deep.equal('Wing In Ground') |
|
66
|
|
|
}) |
|
67
|
|
|
}) |
|
68
|
|
|
|
|
69
|
|
|
describe('getAtonTypeName works', function () { |
|
70
|
|
|
it("ship type 11 is 'Beacon, Cardinal S'", function () { |
|
71
|
|
|
expect( |
|
72
|
|
|
signalkSchema.getAtonTypeName(11) |
|
73
|
|
|
).to.deep.equal('Beacon, Cardinal S') |
|
74
|
|
|
}) |
|
75
|
|
|
}) |
|
76
|
|
|
|